package com.flyduck.system.vo.menu.trans;


import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.flyduck.system.entity.SysMenuEntity;
import com.flyduck.system.vo.menu.SysMenuUpdateReqVO;
import com.google.common.base.Function;


/**
 * @program: flyduck-platform
 * @description:
 * @author: flyduck
 * @create: 2021-02-01 12:42
 **/
public class SysMenuUpdateReqVOToSysMenuEntity implements Function<SysMenuUpdateReqVO, SysMenuEntity> {

    @Override
    public SysMenuEntity apply(SysMenuUpdateReqVO reqVO) {
        SysMenuEntity menuEntity = new SysMenuEntity();
        BeanUtil.copyProperties(reqVO,menuEntity);
        menuEntity.setId(Long.valueOf(reqVO.getId()));
        if(ObjectUtil.isNotNull(reqVO.getParentId())){
            menuEntity.setParentId(Long.valueOf(reqVO.getParentId()));
        }
        menuEntity.setSort(Integer.valueOf(reqVO.getSort()));
        return menuEntity;
    }
}
